<?php
    require_once('../code/global.php');
    require_once('/code/Category.php');
    require_once('/code/Product.php');
    require_once('/code/SiteInfo.php');
    $category=new Category();
    if(isset($_GET['cid'])) $cid=intval($_GET['cid']);
    else $cid=$category->getFirstCategoryId();
    $siteInfo=new SiteInfo();
    $s=$siteInfo->getSiteInfo();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="description" content="<?php echo $s['meta_keyword'] ?>" />  
        <meta name="keyword" content="<?php echo $s['meta_description'] ?>" />
        <title>Galleries | <?php echo $s['site_name'] ?></title>
        <link rel="shortcut icon" href="/styles/images/icon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="/styles/styles.css" />
        <script type="text/javascript" src="/script/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="/script/jquery.captionBox.js"></script>
    </head>
    <body>
        <div id="container">
            <div id="stripe"></div>
            <a href="/" title="<?php echo $s['site_name'] ?>"><div id="header">
            </div></a>
            <div id="menu">
                <ul><li class="current">Galleries</li><li class="seperator">|</li><li><a href="/news">News</a></li><li class="seperator">|</li><li><a href="/about">About us</a></li><li class="seperator">|</li><li><a href="/contact">Contact us</a></li></ul>
            </div>
            <div id="content">
                <div id="leftmenu">
                    <ul>
                        <?php
                            $c=$category->getCategories();
                            $c_count=count($c);
                            $i=0;
                            while($i<$c_count){
                                $item=$cid!=$c[$i]['category_id']?'<a href="/gallery/?cid='.$c[$i]['category_id'].'">'.$c[$i]['name'].'</a>':'<a>'.$c[$i]['name'].'</a>';
                                echo '<li'.($cid==$c[$i]['category_id']?' id="selected"':'').'>'.$item.'</li>'."\n\r";
                                ++$i;
                            }
                        ?>
                    </ul>
                    <!--<ul><li><a href="/gallery/by-photographer">By Photographer...</a></li></ul>-->
                </div>
                <div id="gallrightpanel">
                    <?php
                        $product=new Product();
                        $p=$product->getProductsByCategory($cid);
                        $p_count=count($p);
                        $i=0;
                        if(0==$p_count) echo '<div class="noPhotoDiv">There\'s no item in this category.</div>';
                        while($i<$p_count){
                            echo '<div class="galleryThumbDiv"><a href="/gallery/view/?pid='.$p[$i]['product_id'].'&cid='.$cid.'"><div class="imgWrapper" style="background:url('.$p[$i]['thumb_url'].') no-repeat center"></div><div class="captionBox">'.$p[$i]['subject'].'</div></a></div>'."\n\r";
                            ++$i;
                        }
                    ?>
                </div>
            </div>
            <div id="stripe"></div>
            <div id="footer">
                <?php $siteInfo->getFooterContent($s['site_name']); ?>
            </div>
        </div>
    </body>
</html>
